<%--
 *  File:    MainLeft.jsp 
 *  @Author: Langer Wang 
 *  Date:    2002/2/18
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ page language="java" %>     
<%@ page import="java.util.*,org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>
<%@ page contentType = "text/html;charset=GBK" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<% 
   Category cat = Category.getInstance("jsp.Main.Left");
%>


<%
   String strLanguageCode = (String)request.getParameter("languagecode");
   if (strLanguageCode == null)
   {
     strLanguageCode = (String)session.getAttribute("languagecode");
     if(strLanguageCode == null)
     {
       strLanguageCode = "cn";
       session.setAttribute("languagecode",strLanguageCode);
     }
   }
   else
   {
      session.setAttribute("languagecode",strLanguageCode);
      HashMap userinfo = (HashMap)session.getAttribute("userinfo");
      if(userinfo != null)
      {
         userinfo.put("languagecode",strLanguageCode);
         session.setAttribute("userinfo",userinfo);
      }
   }
   String strAppParam=(String)request.getParameter("app");
   Integer oApp=(Integer)session.getAttribute("app");
   if(strAppParam==null && oApp!=null)
    strAppParam=oApp.toString();
   if(strAppParam==null) 
    strAppParam="1";
   session.setAttribute("app",new Integer(strAppParam));
   
   OvalLabel label = new OvalLabel(strLanguageCode,"Base");
   String Privilegecode = (String)request.getParameter("privilegecode"); 
   boolean isBuffer = false;
   if (Privilegecode == null)
     isBuffer = true;
   
   String strIsFavorite = (String)request.getParameter("isfavorite");
   boolean isFavorite = false;
   if (strIsFavorite != null)
     isFavorite = true;
%>

<html>
<head>
<title>MainLeft</title>
<%
  if(!isBuffer)
  {
%>
    <PageFlow:CheckPageFlow pageName="mainleft"/>
<%
  }
%>

<%
  if (isFavorite)
  {
%>
    <PageFlow:CheckPageFlow pageName="mainleftfavorite"/>
<%
  }
%>

<%
  HashMap mapUser = (HashMap)pageContext.getAttribute("contactinfo");
  if(mapUser == null)
    mapUser = new HashMap();
  HashMap userInfo = (HashMap)session.getAttribute("userinfo");
  if(userInfo == null)
	  userInfo = new HashMap();
%>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link rel="stylesheet" href="css/<%= strLanguageCode %>/csscontent.css" type="text/css">
<script language="JavaScript" src="css/<%= strLanguageCode %>/script.js"></script>
<SCRIPT language=JavaScript src="js/showtree.js"></SCRIPT>
<script language="JavaScript" src="js/cookie.js"></script>
<script language="JavaScript">
<%
if(!isBuffer)
{
  String ModuleLocation = (String)request.getParameter("privilegecode");
  if(ModuleLocation == null)
    ModuleLocation = "";
  Vector v_MenuTree = (Vector)pageContext.getAttribute("menutree");
  if(v_MenuTree == null)
    v_MenuTree = new Vector();
  OvalTree t_MenuTree = new OvalTree(v_MenuTree,"privilegeid","parentprivid","grade");
  t_MenuTree.setRecursiveLimit(2000);
  Vector mt = (Vector)t_MenuTree.getTreeVector(new Integer(-1000),2);  
  String parent = "";
  for(int i = 0;i < mt.size();i++) 
  {
    HashMap temp = (HashMap)mt.get(i);
    Integer grade = (Integer)temp.get("grade");

    if(grade != null && grade.intValue() == 2)
    {
      parent=(String)temp.get("privilegecode");
%>
    var <%= "M"+parent %>=outlookbar.addtitle('<%= temp.get("privilegename") %>');   
<%
    }
    else
    {
      String optional = "?";
      if(temp.get("url") != null && (((String)temp.get("url")).indexOf("?")!=-1))
        optional = "&";
      if (parent != "")
      {
%>    
    outlookbar.additem('<%= temp.get("privilegename") %>',<%= "M" + parent %>,"<%= (String)temp.get("url") + optional +"languagecode=" + strLanguageCode + "&first="  + ModuleLocation + "&second=" + parent + "&third=" + temp.get("privilegecode") + "&" + OvalTools.randomURL() %>");
<%
      }
    }  
  }
}
%>

<%
  if (isFavorite)
  {
    Vector v_fPackage = (Vector)pageContext.getAttribute("favoritepackage");
    if (v_fPackage == null) v_fPackage = new Vector();
    Vector v_fMenu = (Vector)pageContext.getAttribute("favoritemenu");
    if (v_fMenu == null) v_fMenu = new Vector();
    Enumeration e_Menu = v_fMenu.elements();
    
    Integer curMenuPackageId = new Integer(-1);
    if (v_fMenu.size() > 0) curMenuPackageId = (Integer)((HashMap)v_fMenu.get(0)).get("packageid");
    
    HashMap tmpHash = null;
    
    for (int i = 0; i < v_fPackage.size(); i++)
    {
      HashMap tmpPackage = (HashMap)v_fPackage.get(i);
      Integer curPackageId = (Integer)tmpPackage.get("favoritemenuid");
%>
      var <%= "M" + curPackageId %> = outlookbar.addtitle('<%= tmpPackage.get("labelname") %>');
<%
      
      if (curPackageId.compareTo(curMenuPackageId) == 0)
      {
        if (tmpHash != null)
        {
          String optional = "?";
          if (tmpHash.get("url") != null && ((String)tmpHash.get("url")).indexOf("?") != -1)
            optional = "&";
%>
          outlookbar.additem('<%= tmpHash.get("privilegename") %>',<%= "M" + curPackageId %>,"<%= (String)tmpHash.get("url") + optional + "languagecode=" + strLanguageCode + "&first=" + tmpHash.get("moduleprivcode") + "&second=" + tmpHash.get("parentprivcode") + "&third=" + tmpHash.get("privilegecode") + "&" + OvalTools.randomURL() %>");
<%
          tmpHash = null;
        }
        
        while (e_Menu.hasMoreElements())
        {
          HashMap tmpMenu = (HashMap)e_Menu.nextElement();
          
          if (curPackageId.compareTo((Integer)tmpMenu.get("packageid")) == 0)
          {
            String optional = "?";
            if (tmpMenu.get("url") != null && ((String)tmpMenu.get("url")).indexOf("?") != -1)
              optional = "&";
%>
            outlookbar.additem('<%= tmpMenu.get("privilegename") %>',<%= "M" + curPackageId %>,"<%= (String)tmpMenu.get("url") + optional + "languagecode=" + strLanguageCode + "&first=" + tmpMenu.get("moduleprivcode") + "&second=" + tmpMenu.get("parentprivcode") + "&third=" + tmpMenu.get("privilegecode") + "&" + OvalTools.randomURL() %>");
<%
          }
          else
          {
            tmpHash = tmpMenu;
            curMenuPackageId = (Integer)tmpMenu.get("packageid");
            break;
          }
        }
      }
    }
  }
%>
function page_back(obj,referer)
{
//    alert("the referer is="+referer);
//    alert("the menu url is="+getCookie("oval_referer"));
    if(referer=='' || referer.indexOf('Main.jsp')>=0 || referer.indexOf('New')>=0)
    {
//        alert("using menu url!");
        obj.location.href="<%=request.getContextPath()%>/"+getCookie("oval_referer");
    }else
    {
//        alert("using referer url!");
        obj.location.href=referer;
    }
}
function prepareData(id)
{
    setCookie('oval_referer',id);
    deleteCookie("history_length") ;
    deleteCookie("history_url") ;
    deleteCookie("error_length") ;
    setCookie("error_length",0) ;
   // alert("cookie=" + document.cookie);
    document.pageHelper.location.href="<%=request.getContextPath()%>/common/PageHelper.jsp";

}
function setHistoryCookie(name,value)
{
     setCookie(name,value);
}
function  deleteHistoryCookie(a)
{
       deleteCookie(a) ;
}
</script>
<style>

.gray-bg3 {
}

</style>
</head>
<%
  String curPrivCode = (String)session.getAttribute("privcode");
  if (curPrivCode == null)
    curPrivCode = "";
  
  String pageURL = (String)session.getAttribute("pageurl");
  String pageApp = (String)session.getAttribute("pageapp");
  
  String onLoadJob = "";
  if (pageURL != null && pageApp != null)
  {
    session.removeAttribute("pageurl");
    session.removeAttribute("pageapp");
    //session.removeAttribute("privcode");
    
    String moduleCode = (String)session.getAttribute("moduleprivcode");
    if (moduleCode == null) moduleCode = "";
    String parentCode = (String)session.getAttribute("parentprivcode");
    if (parentCode == null) parentCode = "";
    String pageCode = (String)session.getAttribute("privcode");
    if (pageCode == null) pageCode = "";
    
    onLoadJob = "onLoad=\"parent.content.location.href='" + pageURL + "?" + "languagecode=" + strLanguageCode + "&first="  + moduleCode + "&second=" + parentCode + "&third=" + pageCode + "&" + OvalTools.randomURL() + "'\"";
  }
%>
<body <%= onLoadJob %> leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="background:url(images/cn/menv_bg.png) repeat-y;" >
<iframe name="pageHelper" style="display:none"></iframe>

<table width="100%" cellspacing="0" cellpadding="0" border="0" style="background:url(images/cn/menv_bg.png) repeat-y;" >
  <%--tr> 
    <td height="1" background="images/<%= strLanguageCode %>/Top-Short-Line.gif"></td>
  </tr--%>
  
  <iframe id="shortMenu" src="MenuShortcut.jsp" style="display:none"></iframe>
  
  <%--tr class="lftnavbg1" > 
    <td colspan="2" height="3" class="center" > 
      <input type="text" name="menus" value="<%= curPrivCode %>" size="14" class="normalbg" onBlur="shortMenu.frm.privcode.value=this.value" onKeyDown="javascript:if(window.event.keyCode == 13){shortMenu.frm.privcode.value=this.value;shortMenu.page_go();}">
      <input type="image" border="0" name="imageField2" src="images/<%= strLanguageCode %>/go_fy.gif" class="normal" onClick="shortMenu.frm.privcode.value=menus.value;shortMenu.page_go();return false;">
    </td>
    <td width="15" height="3" class="center" >&nbsp;</td>
  </tr--%>
  <tr><td height="30" style="background:url(images/cn/left_topbg.png) repeat-x; line-height:27px; color:#136B89; text-align:center; border-bottom:1px #8DBCF8 solid"><div style="height:25px; line-height:25px; font-size:14px; margin-top:0px; text-align:left; padding-left:10px; font-weight:bold;"><%=label.getLabelName("L_OwnerOrg") + label.getLabelName("L_Colon")%><%= userInfo.get("shortname")%> 
</div>
  </td>
  </tr>
  <tr>
    <td height="27" style="background:url(images/cn/left_lve2.png) repeat-x; line-height:27px;color:#136B89; text-align:left;padding-left:10px;"><%= label.getLabelName("L_CurrentUser") + label.getLabelName("L_Colon") + (String)userInfo.get("username") %></td>
  </tr>
  <tr class="lftnavbg1"> 
    <td colspan="2" class="td_center"><table height="170" cellspacing="0" cellpadding="0" width="100%" border="0">
        <tbody> 
        <tr valign=top> 
          <td id="menutd" height="450" >      </td>
        </tr>
        </tbody> 
      </table><!--<%= label.getLabelName("L_CurrentUser") + label.getLabelName("L_Colon") + (String)mapUser.get("username") %>kkk--><!-- <table width="100%" cellspacing="0" cellpadding="0" border="0" style=" border:1px #ccc solid;">
        <tr> 
          <td class="td_center"><span class="td_center"><!--<%= label.getLabelName("L_OwnerOrg") + label.getLabelName("L_Colon") %>kkk-->
      <!--</span></td>
        </tr>
        <tr>
          <td class="td_center"><!--<%= (String)mapUser.get("shortname") %> -->      <!--</td>
        </tr>
      </table>-->     
      </td>
  </tr>
  <tr><td height="40">&nbsp;</td></tr>
  <tr><td height="40">&nbsp;</td></tr>
</table>
<form name="logout" method="post" action="Dispatcher" target="_parent">
  <input type="hidden" name="pagename" value="mainleft">
  <input type="hidden" name="actionname">
  <input type="hidden" name="languagecode" value="<%=strLanguageCode%>">
  </form>
</body>
<script language="JavaScript">
<%if(!isBuffer || isFavorite){%>
	outlookbar.opentitle=0;
	outlookbar.show();
<%}%>
</script>
<%@include file="/inc/ForbiddenKey.inc"%>
</html>









